define(['app'], function(app) {
	'use strict';

	//商品评价列表
	var factory = function(Http) {
		function get_data_discuss_list(result){
			if(false){
				result = '{"success":true,"msg":"","result":{"page":[{"limit":8,"tPage":1,"cPage":5,"count":20}],"total_count":200,"good_count":198,"normal_count":1,"bad_count":1,"order":[{"order_id":"020","goods":[{"goods_id":1,"goods_name":"螺丝刀","count":10,"product_id":"030","price":200,"discuss_info":[{"id":"011","author":"张三","time":"2017-09-09 9:00:00","score":[{"name":"爱谁谁","point":4}],"comment":"质量高，价格实惠","items":[{"id":"021","author":"李四","time":"2017-09-09 9:00:00","comment":"感谢"}]},{"id":"012","author":"张三","time":"2017-09-09 9:00:00","score":[{"name":"爱谁谁","point":4}],"comment":"质量高","items":[{"id":"022","author":"李四","time":"2017-09-09 9:00:00","comment":"非常感谢"}]}]}]}]},"session":"7311da98bd0f18eb15a96bcb263f4153"}';
				return JSON.parse(result);
			}else
			return result;
		}
		
		// 返回信息
		return {
			//商品评价列表    3中评    1差评      其他为全部
			discuss_list:function(goods_point,nPage,callback,calldone){
				Http.post({
					method:'member.discuss.sellerlist',
					pagelimit:10,
					goods_point:goods_point,
					nPage:nPage
				},function(result){
					if(callback)
						callback(get_data_discuss_list(result).result);
				},function(e){
					
				},function(){
					if(calldone)
						calldone();
				})
			},
			//回复评价
			answer:function(discuss_id,answer,callback) {
				Http.post({
					method: 'member.discuss.answer',
					discuss_id:discuss_id,
					answer:answer
				},function(result) {
					//请求成功
					if(callback)
						callback(result);
				},function(e){
					
				},function(){
					
				})
			}
			
		};
	}

	factory.$inject = [ 'Http' ];
	return app.registerService("Comment_seller", factory);
});